struct Solution {}

impl Solution {
  pub fn is_n_straight_hand(hand: Vec<i32>, group_size: i32) -> bool {
    let mut hand = hand;
    hand.sort();
    let mut i = 0;
    while i < hand.len() {
      let mut now = hand[i];
      hand[i] = -1;
      for _ in 1..group_size {
        let mut offset = 1;
        while offset + i < hand.len() && (hand[offset + i] == now || hand[offset + i] == -1)  {
          offset += 1; 
        }
        if hand[offset + i] != now + 1 {
          return false
        }
        now = hand[offset + i];
        hand[offset+ i] = -1;
      }
      while hand[i] == -1 {
        i += 1;
      }
    }
    true
  }
}